<!DOCTYPE html>
<html lang=ko>
<head>
	<meta charset="UTF-8">
	<title>obj_1.html</title>
	<link rel='stylesheet' type='text/css' href='../css/main.css'/>
	<script>
		//객체 정의
		var obj = new Object();
		obj.x = 100;
		obj.y = 200;
		obj.setData = function(a,b)
					{
						this.x = a;
						this.y = b;
					}
		obj.getData = function()
					{
						var str = '';
						str = "x = " + this.x + "<br>y = " + this.y;
						return str;
					}
		
		function NewObj()
		{
			this.x = 100;
			this.y = 200;
			this.setData = function(a,b)
						{
							this.x=a;
							this.y=b;
						}
			this.getData = function()
						{
						var str = '';
						str = "<br>x = " + this.x + "<br>y = " + this.y;
						return str;
						}
			
		}
		
		//json 타입으로 객체 정의하기
		myObj = 
			{
				x:100,
				y:200,
				setData:function(a,b)
				{
					this.x=a;
					this.y=b;
				},
				getData:function()
				{
					var str = '';
					str = "<br>x = " + this.x + "<br>y = " + this.y;
					return str;
				}
			}
		function Init()
		{
			var r = document.getElementById('result');
			r.innerHTML = obj.getData();
			
			var o2 = new NewObj();
			o2.setData(7777,8888);
			
			r.innerHTML += o2.getData();
			
			myObj.setData(333,444);
			r.innerHTML += myObj.getData();
			
		}
	
	</script>	
</head>
<body>
	<div class=title>자바스크립트 표기 방법으로 객체 생성하기.</div>
	<div id="result"></div>
	
	<script>Init();</script>
	
	
</body>
</html>